﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._06_策略模式
{

    /// <summary>
    /// 具体策略：满减折扣
    /// </summary>
    public class ThresholdDiscount : IDiscountStrategy
    {
        /// <summary>
        /// 满减折扣阈值
        /// </summary>
        private readonly decimal _threshold;
        /// <summary>
        /// 满减折扣金额
        /// </summary>
        private readonly decimal _discountAmount;

        public ThresholdDiscount(decimal threshold, decimal discountAmount)
        {
            _threshold = threshold;
            _discountAmount = discountAmount;
        }

        /// <summary>
        /// 使用折扣
        /// </summary>
        /// <param name="originalPrice"></param>
        /// <returns></returns>
        public decimal ApplyDiscount(decimal originalPrice)
        {
            return originalPrice >= _threshold ? originalPrice - _discountAmount : originalPrice;
        }

    }
}
